<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>标签</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css">  
<link rel="stylesheet" type="text/css" href="css/theme.css"> 
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
<script src="/ppf/js/jquery-1.min.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<script src="/ppf/js/jquery.base64.js" type="text/javascript"></script>    
<script src="/ppf/js/runpage.js" type="text/javascript"></script>
<script src="/ppf/js/bskdo.js" type="text/javascript"></script> 
<script src="/ppf/js/fun.js" type="text/javascript"></script>
<script src="/ppf/js/select.js" type="text/javascript"></script>
<script src="js/bskdlg.js" type="text/javascript"></script>
<script src="lib/bootstrap/js/bootstrap.js"></script>
<style type="text/css">
        #line-chart {
            height:300px;
            width:800px;
            margin: 0px auto;
            margin-top: 1em;
        }
        .brand { font-family: georgia, serif; }
        .brand .first {
            color: #ccc;
            font-style: italic;
        }
        .brand .second {
            color: #fff;
            font-weight: bold;
        }
    </style>
<link rel="stylesheet" type="text/css" href="/widget/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/widget/easyui/themes/icon.css"> 
<script type="text/javascript" src="/widget/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/tree.js"></script>  
</head>

<body>
   <div>         
        <h4>模板管理中心 </h4>         
        
        <div class="container-fluid">
            <div class="row-fluid">
                    
<div class="btn-toolbar">
   <div class="btn-group">  
    <button class="btn btn-primary" id="btn1" onclick="addTreeRootNode({tree:'#tree',dlg:'#dlg1'})">添加根</button>
    <button class="btn btn-primary" id="btn2" onclick="addTreeNode({tree:'#tree',dlg:'#dlg1'});">添加叶子</button>
    <a class="btn btn-primary" onclick="modTreeNode({tree:'#tree',dlg:'#dlg2'});getodx();" id="btn3">重命名</a>
    <button class="btn btn-primary" id="btn3" onclick="delTreeNode({tree:'#tree'});">删除分类</button> 
    <button class="btn btn-primary" id="btn3" onclick="updPidlist();">更新pidlist</button> 
    <a class="btn btn-waring" onclick="location.reload();">刷新</a>   
    </div> 
     
       
 
</div>
<div class="well">

 <div id="myTabContent" class="tab-content">
  <div class="tab-pane active in" id="home">  
  <ul class="easyui-tree" id="tree" data-options="lines:true"	url="./srv/tree.php?tpl=ppf_tpl"></ul>         
  </div>    
  </div>    
</div>  
 <div class="btn-group">
  <a class="btn btn-primary" onclick="openmod();">模板设置</a> 
    <a class="btn btn-primary" onclick="openmod5();">密码设置</a>
   <a class="btn" href="" onclick="return openurl(this,'r.php?t=ppf_tpl_unique&id=');" target="_blank">唯一字段</a> 
   <a class="btn" href="" onclick="return openurl(this,'r.php?t=ppf_tpl_default&id=');" target="_blank">字段默认值</a>  
  </div>
                    
            </div>
        </div>
    </div>      
</body>
</html>

<script>
    var dotype = "m";
    var tbl="ppf_tpl";
    $(function () {
       //readID({ "tpl": queryStr("t"), "do": "r", "id": "1", frmid: "#form1" });        
    }); 
	function openurl(obj,url){
		  var t = $("#tree");
      var node = t.tree('getSelected');
      if(node==undefined){alert("请选择一个节点1");return false;}
	    if(!node||node==null){alert("请选择一个节点2");return false;}
      if(!node.id||node.id==null){alert("节点id为空，请刷新后再试");return;}
		  obj.href=url+node.id;
		  return true;     
  }
  function openurlgen(obj,type){
	   var t = $("#tree");
      var node = t.tree('getSelected');
       if(node==undefined){alert("请选择一个节点1");return false;}
	   if(!node||node==null){alert("请选择一个节点2");return false;}
     if(!node.id||node.id==null){alert("节点id为空，请刷新后再试");return;}
		 obj.href="t.php?t="+node.id+"&htm=0&gen=1&type="+type;
		  return  true;       
  }
  function updPidlist(){
      var t = $("#tree");
      var node = t.tree('getSelected');
       if(node==undefined){alert("请选择一个节点1");return false;}
	   if(!node||node==null){alert("请选择一个节点2");return false;}
     if(!node.id||node.id==null){alert("节点id为空，请刷新后再试");return;}
		 //obj.href="t.php?t="+node.id+"&htm=0&gen=1&type="+type;
     $.post("./srv/treedo.php", {tpl:"updpidlist",tbl:"ppf_tpl",id:node.id}, function (e,f) {
        alert(e);
     });
  }
	function getodx(){
	   var t = $("#tree");
     var node = t.tree('getSelected'); 	
	   if(node==undefined){return;}
	   if(!node||node==null){return;}	
		 $.post("./srv/treedo.php", {tpl:"getodx",tbl:"ppf_tpl",id:node.id}, function (e,f) {
		 $("#dlg2 #odx").val($.trim(e));}); 		 
	}//模板设置
    function openmod(){
       var t = $("#tree");
       var node = t.tree('getSelected');
      if(node==undefined){alert("请选择一个节点1");return;}
	    if(!node||node==null){alert("请选择一个节点2");return;}
       if(!node.id||node.id==null){alert("节点id为空，请刷新后再试");return;}
      readID({ "tpl":"ppf_tpl", "do": "r", "id": node.id, frmid: "#dlg3" }); 	
      $("#dlg3").modal('show');	 	
    }	
    function form3do(){
       SaveAM({tpl:"ppf_tpl","do":"m",id:$('#dlg3 #id').val(),frmid:'#dlg3',showok:'','callback':'amcallback'});
      $("#dlg3").modal('hide');	  
    }
	 function form4do(){
      SaveAM({tpl:"ppf_tpl","do":"m",id:$('#dlg4 #id').val(),frmid:'#dlg4',showok:'','callback':'amcallback'});
      $("#dlg4").modal('hide');	  
   }
	//密码设置
	function openmod5(){
		  var t = $("#tree");
      var node = t.tree('getSelected');
      if(node==undefined){alert("请选择一个节点1");return;}
	    if(!node||node==null){alert("请选择一个节点2");return;}
      if(!node.id||node.id==null){alert("节点id为空，请刷新后再试");return;}
      readID({ "tpl":"ppf_tpl", "do": "r", "id": node.id, frmid: "#dlg5" }); 	
      $("#dlg5").modal('show');	
	}
	 function form5do(){
       SaveAM({tpl:"ppf_tpl","do":"m",id:$('#dlg5 #id').val(),frmid:'#dlg5',showok:'','callback':'amcallback'});
      $("#dlg5").modal('hide');	  
  }

</script>

<div class="modal small hide" id="dlg1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="label">节点</h3>
    </div>
    <div class="modal-body">
<form id="form1">
<label>节点名称</label>  <input id="name" type="text" value="" maxlength="30"> 
 <label>排序(数字从小到大排序)</label>  <input id="odx" type="text" value="0"  onkeyup="value=value.replace(/[^0-9]/ig,'')">  
 <input type="text" id="id" style="display:none;" value="" disabled/>
</form> 
    </div>
    <div class="modal-footer">
        <button class="btn btn-danger" onclick="addTreeNodeDo('#dlg1')">确认</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        
    </div>
</div>

<div class="modal small hide" id="dlg2" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="label">修改</h3>
    </div>
    <div class="modal-body">
<form id="form1">
<label>节点名称</label>  <input id="name" type="text" value="" maxlength="30"> 
<label>排序(数字大在前)</label>  <input id="odx" type="text" value="0"  onkeyup="value=value.replace(/[^0-9]/ig,'')" >   
 <input type="text" id="id" style="display:none;" value=""/>
</form> 
    </div>
    <div class="modal-footer">
        <button class="btn btn-danger" onclick="modTreeNodeDo('#dlg2')">确认</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
        
    </div>
</div>

<!--模板设置-->
<div class="modal  hide " id="dlg3" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="label">模板设置</h3>
    </div>
    <div class="modal-body">
<form id="form3">    
<input type="text" id="id"  style="display:none;"/>   
<label>模板(tpl)</label>
<input type="text" id="tpl" value="" />   
<label>对应表(table)</label>
<input type="text" id="tblname" value="" />  
<label>主键 primary key</label>
<input type="text" id="tblkey" value="id" />        <br/>
<label>主键种子数(1:自增/time：时间戳或数字) </label>
<input type="text" id="tblseed" value="time" />     
<label>使用前缀(主键使用数据前缀)</label>
<input type="checkbox" id="usepre" value="0"  />      <br/> 
</form> 
    </div>
    <div class="modal-footer">
        <button class="btn btn-danger" onclick="form3do()">确认</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>        
    </div>
</div>

<!--密码模板设置-->
<div class="modal  hide " id="dlg5" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="label">密码设置</h3>
    </div>
    <div class="modal-body">
<form id="form5">    
<input type="text" id="id"  style="display:none;"/>    
<label>密码字段(网页控件id) </label>
<input type="text" id="ctrlpass" value="" />         <br/>
<label>md5字段(没有请留空)</label>
<input type="text" id="tblmd5" value="" />   
<label>sha1字段(没有请留空)</label>
<input type="text" id="tblsha1" value="" />      
</form> 
    </div>
    <div class="modal-footer">
        <button class="btn btn-danger" onclick="form5do()">确认</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>        
    </div>
</div>
